package com.elex.ram;

import java.io.File;
import java.io.FileInputStream;

import org.json.JSONObject;

public class CheckJson {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String strBase = args[0];
		System.out.println(strBase);
		File file = new File(strBase);
		if(file.exists() && file.isDirectory()) {
			File[] fileList = file.listFiles();
			for(File json : fileList) {
				if(json.getName().endsWith(".txt")) {
					try {
						System.out.println("\nhandle: " + json.getAbsolutePath());
						FileInputStream in = new FileInputStream(json);
						byte[] readBytes = new byte[in.available()];
						in.read(readBytes);
						in.close();
						String strText = new String(readBytes, "utf-8");
						JSONObject obj = new JSONObject(strText);
						obj = null;
					} catch (Exception e) {
						System.out.println("    !!! Error: " + e.getMessage());
					}
				}
			}
		} else {
			System.out.println("!!! Error: Folder not exist.");
		}
	}

}
